﻿Imports System.Security.Cryptography


Module Core

    Public Function Roll(ByVal iRndMin As Integer, ByVal iRndMax As Integer)
        Static prng As Random

        If prng Is Nothing Then
            Dim rng As New System.Security.Cryptography.RNGCryptoServiceProvider
            Dim seed() As Byte = New Byte(3) {}

            'Using the Crypto RNG, create our seed (1-255)
            rng.GetBytes(seed)

            'Create the Pseudo-Random Number Generator...
            prng = New Random(BitConverter.ToInt32(seed, 0))
        End If

        'And give it our range...
        Return prng.Next(iRndMin, iRndMax)
    End Function
End Module
